package com.espirit.eap.manager;

import javax.persistence.Entity;
import javax.persistence.Transient;

import com.espirit.eap.ICheckModelDuplicateInfo;
import com.espirit.eap.annotation.ModelDisplayProperty;

@Entity
@ModelDisplayProperty(value="text")
public class EntityStatus extends ItemFiling implements ICheckModelDuplicateInfo{
	private static final long serialVersionUID = -958432403053163256L;
	
	public static final String Init = "Init";
	public static final String Refer = "Refer";
	public static final String Accept = "Accept";
	public static final String Reject = "Reject";
	public static final String Deleted = "Deleted";
	public EntityStatus(){
		
	}
	public EntityStatus(int itemNbr, String code, String enName,String cnName) {
		super(itemNbr,code,enName,cnName);	
	}
	
	@Transient
	public boolean isAccept(){
		return Accept.equals(getCode());
	}
	
	@Transient
	public boolean isReject(){
		return Reject.equals(getCode());
	}
	
	@Transient
	public boolean isRefer(){
		return Refer.equals(getCode());
	}
	
	@Transient
	public boolean isDeleted(){
		return Deleted.equals(getCode()); 
	}
	
	@Transient
	public boolean isInited(){
		return Init.equals(getCode());
	}
	
	@Override
	public String[] gatherProperties() {
		return new String[]{"code"};
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof EntityStatus){
			if (this != null && obj == null) return false;
			if (this.getCode().equals(((EntityStatus)obj).getCode())) return true;
		} else {
			return false;
		}
		return false;
	}
	
	
}
